#include"../include/p.h"
#include<stdio.h>
//编写子函数和服务器进行通信
//参数1 通信的socket对象 描述符
//返回值 结束返回-1，不结束返回0；
int tcp_com(int tcp_socket)
{
	getchar();
	char buf[50]={'\0'};
	char cmd[50]={'\0'};
	char filename[50]={'\0'};
	while(1)	
	{
		memset(buf,'\0',sizeof(buf));
		//printf("fgets qian\n");
		fgets(buf,sizeof(buf),stdin);
		//printf("fgets hou\n");
		//scanf("%s",buf);
    	//这里系统调用函数send，和write类似	
		send(tcp_socket,buf,sizeof(buf),0);	
		if(strncmp(buf,"quit",4)==0)		
		{
			return -1;
			break;
		}
		//解析字符串
		parseStr(buf,cmd,filename);
		int ret=do_work(tcp_socket,cmd,filename);
		
		if(ret<0)
		{
			printf("client tcp_com fail\n");
		}
		else
		{
			printf("do work成功\n");
		}
	}
	return 0;
}
